/*
 * Connection.java
 *
 * Created on 13 maart 2008, 15:32
 *
 * @author wijnand.schepens@hogent.be
 */
package diagram.connections;

import data.PredefinedObjects;
import diagram.*;
import diagram.locations.Location;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.geom.Line2D;
import java.io.Serializable;

public abstract class Connection extends Graphical implements Serializable {

    private Location source;
    private Location target;
    private boolean selected = false;
    private Line2D line;

    public Connection(Location source, Location target) {
        this.source = source;
        this.target = target;
        line = new Line2D.Double();
        line.setLine(getSource().getX(), getSource().getY(), getTarget().getX(), getTarget().getY());

    }

    public abstract void paint(Graphics2D g);

    public boolean contains(int x, int y){
        return false;
    }

    public boolean isContainedIn(Rectangle rect) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    /**
     * @return the source
     */
    public Location getSource() {
        return source;
    }

    /**
     * @param source the source to set
     */
    public void setSource(Location source) {
        this.source = source;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    /**
     * @return the target
     */
    public Location getTarget() {
        return target;
    }

    /**
     * @param target the target to set
     */
    public void setTarget(Location target) {
        this.target = target;
    }

    /**
     * @return the line
     */
    public Line2D getLine() {
        return line;
    }

    /**
     * @param line the line to set
     */
    public void setLine(Line2D line) {
        this.line = line;
    }
}
